package playground.fibu.ejb.entity;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table
public class Account extends BaseEntity {

	private String iban;
	private String accountName;

	@OneToMany(mappedBy = "debitAccount")
	private List<Booking> debitBooking;

	public String getIban() {
		return iban;
	}

	public void setIban(String iban) {
		this.iban = iban;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public List<Booking> getDebitBooking() {
		return debitBooking;
	}

	// This must return true for another Account object with same key/id.
	public boolean equals(Object other) {
		return other instanceof Account && (id != null) ? id
				.equals(((Account) other).id) : (other == this);
	}

	// This must return the same hashcode for every Account object with the same
	// id.
	public int hashCode() {
		return id != null ? this.getClass().hashCode() + id.hashCode() : super
				.hashCode();
	}

	// Override Object#toString() so that it returns a human readable String
	// representation.
	// It is not required by the Converter or so, it just pleases the reading in
	// the logs.
	public String toString() {
		return "Account[" + id + "," + accountName + "," + iban + "]";
	}

}
